﻿<Window x:Class="SimpleDbBrowser.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:uc="clr-namespace:SimpleDbBrowser.UserControls"
        Title="{Binding Path=DisplayName}" MinHeight="480" MinWidth="640"
        x:Name="This"
        DataContext="{Binding ElementName=This, Path=ViewModel}" Icon="/SimpleDbBrowser;component/Resources/uglycloud.ico">
    <Grid Style="{StaticResource LayoutGrid}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="50" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition MinWidth="50" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition MinWidth="50" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="2*" MinHeight="50" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="2*" MinHeight="50" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="1*" MinHeight="50"/>
        </Grid.RowDefinitions>
        
        <Menu Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5">
            <MenuItem Header="_File" >
                <MenuItem Header="_Options" Command="{Binding ElementName=This, Path=DisplayOptions}" />
                <Separator />
                <MenuItem Header="E_xit" Command="{Binding ExitApplication}"/>
            </MenuItem>
        </Menu>
        
        <ScrollViewer Grid.Column="4" Grid.Row="1" Grid.RowSpan="3" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
            <StackPanel>
                <Expander Header="{Binding Path=CreateDomainModel.DisplayName}" x:Name="expCreateDomain" >
                    <uc:CreateDomainUserControl x:Name="ucCreateDomain" DataContext="{Binding Path=CreateDomainModel}" />
                </Expander>
                <Expander Header="{Binding Path=DeleteDomainModel.DisplayName}" x:Name="expDeleteDomain">
                    <uc:DeleteDomainUserControl x:Name="ucDeleteDomain" DataContext="{Binding Path=DeleteDomainModel}" />
                </Expander>
                <Expander Header="{Binding Path=PutAttributeModel.DisplayName}" x:Name="expPutAttr">
                    <uc:PutAttributeUserControl x:Name="ucPutAttr" DataContext="{Binding Path=PutAttributeModel}" />
                </Expander>
                <Expander Header="{Binding DeleteAttributeModel.DisplayName}" x:Name="expDeleteAttr">
                    <uc:DeleteAttributeUserControl x:Name="ucDeleteAttribute" DataContext="{Binding Path=DeleteAttributeModel}" />
                </Expander>
                <Expander Header="{Binding CustomSelectModel.DisplayName}" x:Name="expCustomSelect" >
                    <uc:CustomSelectUserControl x:Name="ucCustomSelect" DataContext="{Binding Path=CustomSelectModel}" />
                </Expander>
            </StackPanel>
        </ScrollViewer>
        
        <GridSplitter Grid.Column="1" Grid.Row="1" Grid.RowSpan="3"
                      HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                      ResizeDirection="Columns" ResizeBehavior="PreviousAndNext" 
                      MinWidth="5" MinHeight="5" IsTabStop="False" />
        <GridSplitter Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="5"
                      HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                      ResizeDirection="Rows" ResizeBehavior="PreviousAndNext" 
                      MinWidth="5" MinHeight="5" IsTabStop="False" />
        <GridSplitter Grid.Column="2" Grid.Row="2" 
                      HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                      ResizeDirection="Rows" ResizeBehavior="PreviousAndNext"
                      MinWidth="5" MinHeight="5" IsTabStop="False" />
        <GridSplitter Grid.Column="3" Grid.RowSpan="3" Grid.Row="1"
                      HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                      ResizeDirection="Columns" ResizeBehavior="PreviousAndNext" 
                      MinWidth="5" MinHeight="5" IsTabStop="False" />
        
        <DockPanel Grid.Row="1" Grid.Column="0" Grid.RowSpan="3">
            <DockPanel DockPanel.Dock="Top" Style="{StaticResource TitlePanel}">
                <Button DockPanel.Dock="Right" Command="{Binding RefreshDomains}" Style="{StaticResource RefreshButton}" ToolTip="Refresh the list of domains" />
                <Label Content="Domains" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Style="{StaticResource GroupTitle}" />
            </DockPanel>
            <ListView x:Name="lstDomains"  
                  IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Path=Domains}" SelectedItem="{Binding SelectedDomain}" SelectionMode="Single">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="Domain Name" />
                    </GridView>
                </ListView.View>
            </ListView>
        </DockPanel>
        
        <DockPanel Grid.Column="2" Grid.Row="1">
            <DockPanel DockPanel.Dock="Top" Style="{StaticResource TitlePanel}" >
                <Button DockPanel.Dock="Right" Command="{Binding RefreshItems}" Style="{StaticResource RefreshButton}" ToolTip="Refresh the list of domain items" />
                <Label Content="Domain Items" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Style="{StaticResource GroupTitle}" />
            </DockPanel>
            <ListView Name="lstItems" 
                      IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Path=Items}" SelectedItem="{Binding SelectedItem}" SelectionMode="Single">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="Item Name" DisplayMemberBinding="{Binding Name}" />
                    </GridView>
                </ListView.View>
            </ListView>
        </DockPanel>
        
        <TextBox Grid.Row="5" Grid.ColumnSpan="5" x:Name="txtLogging" 
                 IsReadOnly="True" Text="{Binding Path=TraceLog, Mode=OneWay}" 
                 HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" 
                 Margin="0"
                 TextChanged="HandleTraceLogTextChanged" />
        
        <DockPanel Grid.Column="2" Grid.Row="3">
            <DockPanel DockPanel.Dock="Top" Style="{StaticResource TitlePanel}">
                <Button x:Name="btnRefreshAttributes" DockPanel.Dock="Right" Command="{Binding RefreshAttributes}" Style="{StaticResource RefreshButton}" ToolTip="Refresh the list of item attributes" />
                <Label Content="Item Attributes" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Style="{StaticResource GroupTitle}" />
            </DockPanel>
            <ListView x:Name="lstAttrs"
                      IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Path=Attributes}" SelectedItem="{Binding SelectedAttribute}" SelectionMode="Single" >
                <ListView.View>
                    <GridView >
                        <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" />
                        <GridViewColumn Header="Value" DisplayMemberBinding="{Binding Value}" />
                    </GridView>
                </ListView.View>
            </ListView>
        </DockPanel>
    
    </Grid>
</Window>
